/*-
 * Copyright (c) 2014 Shang-Rong Cai. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $ trigrid.h    Rev. 0.1.0    2014-05-15T11:45+08:00 $
 */

#include <stdlib.h>
#include <stdint.h>

#include <pregrid.h>

#ifndef TRIGRID_H
#define TRIGRID_H


#define TRIGRID_PROBLEM_DIMENSION 2  /* Default problem dimension */
#define TRIGRID_SPATIAL_DIMENSION 3  /* Default spatial dimension */

#define TRIGRID_NOT_SET_RCTR 0  /* Unstructured grid of triangle */
#define TRIGRID_DEFAULT_RCTR 2  /* Square divide as two triangle */
#define TRIGRID_DEFAULT_TRVZ 3  /* Each triangle has three vertices */

typedef struct
{
    size_t pdim;  /* Problem dimension */
    size_t sdim;  /* Spatial dimension */

    size_t rctr;  /* Square divide as two triangle */
    size_t trvz;  /* Each triangle has three vertices */

    size_t vtxz;  /* Number of vertices */
    size_t elmz;  /* Number of elements */

    double *coor;  /* Coordinates of vertices */
    int *vlst;  /* Element vertices list */
} trigrid_t;


int trigrid_create(double x0, double x1, double y0, double y1, size_t mz, size_t nz, trigrid_t *tgrd);

int trigrid_delete(trigrid_t *tgrd);

int trigrid_stdout(const trigrid_t *tgrd);

int trigrid_save_vtk(const trigrid_t *tgrd, const char *vtk_file);


int trigrid_create_cidk(const trigrid_t *tgrd, cidk_t *cidk);

int trigrid_delete_cidk(cidk_t *cidk);


#endif
